from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware

from user.router import router as user_router
from tours.router import router as tour_router
from booking.router import router as booking_router

app = FastAPI(
    openapi_prefix="/api",
    title="Booking service"
)

app.include_router(
    user_router,
    prefix="/user",
    tags=["User"]
)

app.include_router(
    tour_router,
    prefix="/tour",
    tags=["Tour"]
)

app.include_router(
    booking_router,
    prefix="/booking",
    tags=["Booking"]
)

origins = ['http://127.0.0.1:3000']

app.add_middleware(
    CORSMiddleware,
    allow_origins=origins,
    allow_credentials=True,
    allow_methods=[
        "GET",
        "POST",
        "OPTIONS",
        "DELETE",
        "PATCH",
        "PUT"
    ],
    allow_headers=[
        "Accept",
        "Accept-Encoding",
        "Accept-Language",
        "Connection",
        "Content-Length",
        "Content-Type",
        "Dnt",
        "Host",
        "Origin",
        "Referer",
        "Sec-Ch-Ua",
        "Sec-Ch-Ua-Mobile",
        "Sec-Ch-Ua-Platform",
        "Sec-Fetch-Dest",
        "Sec-Fetch-Mode",
        "Sec-Fetch-Site",
        "User-Agent",
        "Content-Type",
        "Set-Cookie",
        "Access-Control-Allow-Headers",
        "Access-Control-Allow-Origin",
        "Authorization"
    ],
)
